// MESSAGE PRICISE_IMU support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief PRICISE_IMU message
 *
 * PRICISE IMU PARAMETERS
 */
struct PRICISE_IMU : mavlink::Message {
    static constexpr msgid_t MSG_ID = 19;
    static constexpr size_t LENGTH = 88;
    static constexpr size_t MIN_LENGTH = 88;
    static constexpr uint8_t CRC_EXTRA = 38;
    static constexpr auto NAME = "PRICISE_IMU";


    uint64_t time_boot_ms; /*< [ms] Timestamp (time since system boot). */
    float xgyro; /*<  The x axis gyro(-838.8608..838.8608). */
    float ygyro; /*<  The y axis gyro(-838.8608..838.8608). */
    float zgyro; /*<  The z axis gyro(-838.8608..838.8608). */
    float xacc; /*<  The x axis acc(-83.88608..83.88608). */
    float yacc; /*<  The y axis acc(-83.88608..83.88608). */
    float zacc; /*<  The z axis acc(-83.88608..83.88608). */
    float xmagn; /*<  The x axis magn(-327.68..327.68). */
    float ymagn; /*<  The y axis magn(-327.68..327.68). */
    float zmagn; /*<  The z axis magn(-327.68..327.68). */
    uint8_t magnFlg; /*<  valid component(0:invalid 1:valid). */
    float Hbar; /*<  The Hbar(0..6553.6). */
    uint8_t HbarFlg; /*<  valid component(0:invalid 1:valid). */
    float pitch; /*<  The pitch(-90..90). */
    float roll; /*<  The roll(-180..180). */
    float yaw; /*<  The yaw(0,360). */
    float vel_e; /*<  The east vel(-838.8608..838.8608). */
    float vel_n; /*<  The north vel(-838.8608..838.8608). */
    float vel_u; /*<  The up vel(-838.8608..838.8608). */
    float longitude; /*<  The longitude(-838.8608..838.8608). */
    float latitude; /*<  latitude(-838.8608..838.8608). */
    float hight; /*<  The hight(-838.8608..838.8608). */
    uint8_t mode; /*<  mode component(1..3). */
    uint8_t scene; /*<  scene component(1..5). */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  time_boot_ms: " << time_boot_ms << std::endl;
        ss << "  xgyro: " << xgyro << std::endl;
        ss << "  ygyro: " << ygyro << std::endl;
        ss << "  zgyro: " << zgyro << std::endl;
        ss << "  xacc: " << xacc << std::endl;
        ss << "  yacc: " << yacc << std::endl;
        ss << "  zacc: " << zacc << std::endl;
        ss << "  xmagn: " << xmagn << std::endl;
        ss << "  ymagn: " << ymagn << std::endl;
        ss << "  zmagn: " << zmagn << std::endl;
        ss << "  magnFlg: " << +magnFlg << std::endl;
        ss << "  Hbar: " << Hbar << std::endl;
        ss << "  HbarFlg: " << +HbarFlg << std::endl;
        ss << "  pitch: " << pitch << std::endl;
        ss << "  roll: " << roll << std::endl;
        ss << "  yaw: " << yaw << std::endl;
        ss << "  vel_e: " << vel_e << std::endl;
        ss << "  vel_n: " << vel_n << std::endl;
        ss << "  vel_u: " << vel_u << std::endl;
        ss << "  longitude: " << longitude << std::endl;
        ss << "  latitude: " << latitude << std::endl;
        ss << "  hight: " << hight << std::endl;
        ss << "  mode: " << +mode << std::endl;
        ss << "  scene: " << +scene << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << time_boot_ms;                  // offset: 0
        map << xgyro;                         // offset: 8
        map << ygyro;                         // offset: 12
        map << zgyro;                         // offset: 16
        map << xacc;                          // offset: 20
        map << yacc;                          // offset: 24
        map << zacc;                          // offset: 28
        map << xmagn;                         // offset: 32
        map << ymagn;                         // offset: 36
        map << zmagn;                         // offset: 40
        map << Hbar;                          // offset: 44
        map << pitch;                         // offset: 48
        map << roll;                          // offset: 52
        map << yaw;                           // offset: 56
        map << vel_e;                         // offset: 60
        map << vel_n;                         // offset: 64
        map << vel_u;                         // offset: 68
        map << longitude;                     // offset: 72
        map << latitude;                      // offset: 76
        map << hight;                         // offset: 80
        map << magnFlg;                       // offset: 84
        map << HbarFlg;                       // offset: 85
        map << mode;                          // offset: 86
        map << scene;                         // offset: 87
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> time_boot_ms;                  // offset: 0
        map >> xgyro;                         // offset: 8
        map >> ygyro;                         // offset: 12
        map >> zgyro;                         // offset: 16
        map >> xacc;                          // offset: 20
        map >> yacc;                          // offset: 24
        map >> zacc;                          // offset: 28
        map >> xmagn;                         // offset: 32
        map >> ymagn;                         // offset: 36
        map >> zmagn;                         // offset: 40
        map >> Hbar;                          // offset: 44
        map >> pitch;                         // offset: 48
        map >> roll;                          // offset: 52
        map >> yaw;                           // offset: 56
        map >> vel_e;                         // offset: 60
        map >> vel_n;                         // offset: 64
        map >> vel_u;                         // offset: 68
        map >> longitude;                     // offset: 72
        map >> latitude;                      // offset: 76
        map >> hight;                         // offset: 80
        map >> magnFlg;                       // offset: 84
        map >> HbarFlg;                       // offset: 85
        map >> mode;                          // offset: 86
        map >> scene;                         // offset: 87
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
